package com.xy.work.template.base.handler;//package com.xy.work.template.base.handler;
//import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
//import com.alibaba.csp.sentinel.slots.block.BlockException;
//import com.alibaba.csp.sentinel.slots.block.authority.AuthorityException;
//import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
//import com.alibaba.csp.sentinel.slots.block.flow.FlowException;
//import com.alibaba.csp.sentinel.slots.block.flow.param.ParamFlowException;
//import com.alibaba.csp.sentinel.slots.system.SystemBlockException;
//import com.xy.work.template.base.utils.CommonUtil;
//import com.xy.work.template.common.enums.ApiCodeEnum;
//import org.springframework.stereotype.Component;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import com.xy.work.template.base.entity.JsonResult;
///**
// * 配置流量sentinel控制状态异常返回数据
// * @author niuniu
// */
//@Component
//public class UrlBlockHandler implements BlockExceptionHandler {
//    @Override
//    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BlockException e) throws Exception {
//        JsonResult data=null;
//        if(e instanceof FlowException){
//            data= JsonResult.error(ApiCodeEnum.SYSTEM_BLOCK_CURRENT_LIMITING);
//        }
//        else if(e instanceof DegradeException){
//            data= JsonResult.error(ApiCodeEnum.SYSTEM_BLOCK_DEMOTION);
//        }
//        else if(e instanceof ParamFlowException){
//            data= JsonResult.error(ApiCodeEnum.SYSTEM_BLOCK_HOT_SPOT_PARAMETERS);
//        }
//        else if(e instanceof SystemBlockException){
//            data= JsonResult.error(ApiCodeEnum.SYSTEM_BLOCK_ERROR);
//        }
//        else if(e instanceof AuthorityException){
//            data= JsonResult.error(ApiCodeEnum.SYSTEM_BLOCK_NOT_AUTHORITY);
//        }else {
//            data= JsonResult.error(ApiCodeEnum.SYSTEM_ERROR);
//        }
//        CommonUtil.sendJsonMessage(httpServletResponse,data);
//    }
//}
